<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Area - Github style</title>

    <link href="../../assets/styles.css" rel="stylesheet" />

    <style>
      
        #wrapper {
      padding-top: 20px;
      padding-left: 10px;
      padding-right: 10px;
      background: #fff;
      border: 1px solid #ddd;
      box-shadow: 0 22px 35px -16px rgba(0, 0, 0, 0.1);
      max-width: 650px;
      margin: 35px auto;
    }
    
    .github-style {
      clear: both;
      font-weight: 400;
      height: 40px;
      margin-left: 6px;
    }
    
    .github-style a {
      color: #0366d6;
      font-size: 18px;
    }
    
    .github-style .cmeta {
      display: block;
      color: #777;
      font-weight: 400;
    }
    
    .github-style .userimg {
      float: left;
      display: block;
      border-radius: 3px;
    }
    
    .github-style .userdetails {
      float: left;
      margin-left: 10px;
    }
      
    </style>

    <script>
      window.Promise ||
        document.write(
          '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
        )
      window.Promise ||
        document.write(
          '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
        )
      window.Promise ||
        document.write(
          '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
        )
    </script>

    
    <script src="https://cdn.jsdelivr.net/npm/react@17.0.2/umd/react.production.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/prop-types@15.8.1/prop-types.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
    <script src="../../../dist/apexcharts.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/react-apexcharts@1.7.0/dist/react-apexcharts.iife.min.js"></script>
    

    <script>
      // Replace Math.random() with a pseudo-random number generator to get reproducible results in e2e tests
      // Based on https://gist.github.com/blixt/f17b47c62508be59987b
      var _seed = 42;
      Math.random = function() {
        _seed = _seed * 16807 % 2147483647;
        return (_seed - 1) / 2147483646;
      };
    </script>

    <script src="../../assets/github-data.js"></script>
  </head>

  <body>
    
    <div id="app"></div>

    <div id="html">
      &lt;div id=&quot;wrapper&quot;&gt;
  &lt;div id=&quot;chart-months&quot;&gt;
  &lt;ReactApexChart options={state.options} series={state.series} type=&quot;area&quot; height={180} /&gt;
&lt;/div&gt;

  &lt;h5 class=&quot;github-style&quot;&gt;
    &lt;img class=&quot;userimg&quot; src=&quot;https://picsum.photos/200/200/?image=1031&quot; data-hovercard-user-id=&quot;634573&quot; alt=&quot;&quot; width=&quot;38&quot; height=&quot;38&quot; /&gt;
    &lt;div class=&quot;userdetails&quot;&gt;
      &lt;a class=&quot;username&quot;&gt;coder&lt;/a&gt;
      &lt;span class=&quot;cmeta&quot;&gt;
        &lt;span class=&quot;commits&quot;&gt;&lt;/span&gt; commits
      &lt;/span&gt;
    &lt;/div&gt;
  &lt;/h5&gt;

  &lt;div id=&quot;chart-years&quot;&gt;
  &lt;ReactApexChart options={state.optionsYears} series={state.seriesYears} type=&quot;area&quot; height={150} /&gt;
&lt;/div&gt;
&lt;/div&gt;
    </div>

    <script type="text/babel">
      const ApexChart = () => {
        const [state, setState] = React.useState({
          
            series: [{
              name: 'commits',
              data: githubdata.series
            }],
            options: {
              chart: {
                id: 'chartyear',
                type: 'area',
                height: 180,
                background: '#F6F8FA',
                toolbar: {
                  show: false,
                  autoSelected: 'pan'
                },
                events: {
                  mounted: function (chart) {
                    var commitsEl = document.querySelector('.cmeta span.commits');
                    var commits = chart.getSeriesTotalXRange(chart.w.globals.minX, chart.w.globals.maxX)
              
                    commitsEl.innerHTML = commits
                  },
                  updated: function (chart) {
                    var commitsEl = document.querySelector('.cmeta span.commits');
                    var commits = chart.getSeriesTotalXRange(chart.w.globals.minX, chart.w.globals.maxX)
              
                    commitsEl.innerHTML = commits
                  }
                }
              },
              colors: ['#FF7F00'],
              stroke: {
                width: 0,
                curve: 'monotoneCubic'
              },
              dataLabels: {
                enabled: false
              },
              fill: {
                opacity: 1,
                type: 'solid'
              },
              yaxis: {
                show: true,
                forceNiceScale: true
              },
              xaxis: {
                type: 'datetime',
              }
            },
          
            seriesYears: [{
              name: 'commits',
              data: githubdata.series
            }],
            optionsYears: {
              chart: {
                height: 150,
                type: 'area',
                background: '#F6F8FA',
                toolbar: {
                  autoSelected: 'selection',
                },
                brush: {
                  enabled: true,
                  target: 'chartyear'
                },
                selection: {
                  enabled: true,
                  xaxis: {
                    min: new Date('15 Feb 2016').getTime(),
                    max: new Date('14 Feb 2017').getTime()
                  }
                },
              },
              colors: ['#7BD39A'],
              dataLabels: {
                enabled: false
              },
              stroke: {
                width: 0,
                curve: 'monotoneCubic'
              },
              fill: {
                opacity: 1,
                type: 'solid'
              },
              legend: {
                position: 'top',
                horizontalAlign: 'left'
              },
              xaxis: {
                type: 'datetime'
              },
            },
          
          
        });

        

        return (
          <div>
            <div id="wrapper">
                <div id="chart-months">
                <ReactApexChart options={state.options} series={state.series} type="area" height={180} />
              </div>
              
                <h5 class="github-style">
                  <img class="userimg" src="https://picsum.photos/200/200/?image=1031" data-hovercard-user-id="634573" alt="" width="38" height="38" />
                  <div class="userdetails">
                    <a class="username">coder</a>
                    <span class="cmeta">
                      <span class="commits"></span> commits
                    </span>
                  </div>
                </h5>
              
                <div id="chart-years">
                <ReactApexChart options={state.optionsYears} series={state.seriesYears} type="area" height={150} />
              </div>
              </div>
            <div id="html-dist"></div>
          </div>
        );
      }

      const domContainer = document.querySelector('#app');
      ReactDOM.render(<ApexChart />, domContainer);
    </script>

    
  </body>
</html>
